/**
 * 滑动变阻器
 */
Rhostat = Widget.extend({
	ctor:function(parent){
		this._super();
		parent.addChild(this,30);
		this.init();
		this.setTag(TAG_RHOSTAT);
	},
	init:function(){
		this.setCascadeOpacityEnabled(true);
		this.setScale(0.8);

		// 滑动变阻器
		var rhostat = new Button(this, 10, TAG_RHOSTAT_BODY, "#rhostat.png", this.callback);
		rhostat.setPosition(cc.p(1250,200));
		//  滑片
		var sliding = new Button(rhostat, 10, TAG_SLIDING, "#sliding.png", this.callback);
		sliding.setPosition(cc.p(333,165));
		
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callNext.retain();
	},
	callback:function (p){
		var action=gg.flow.flow.action;
		switch(p.getTag()){
		case TAG_SLIDING:
			if(action==ACTION_DO1){
				var move = cc.moveTo(1,cc.p(230,169));
				var seq = cc.sequence(cc.callFunc(function() {
					var show = new ShowTip("调整滑片，至电流表读数为1.0 A，\n等待3分钟",cc.p(995,530),true);
					var finger = ll.run.getChildByTag(TAG_AMMETER).getChildByTag(TAG_AMMETER_BODY).getChildByTag(TAG_AMMETER_FINGER);
					var rot1 = cc.rotateBy(0.5, 30);
					var rot2 = cc.rotateBy(0.5, -10);
					var rot3 = cc.rotateBy(0.5, 5);
					var seq1 = cc.sequence(rot1,rot2,rot3);
					finger.runAction(seq1);
				}, this),move,cc.delayTime(0.7),cc.callFunc(function() {
					ll.run.clock.loadTip("#tool/tip1.png");
					ll.run.clock.doTime(3,0);
					var kerosene1 = ll.run.getChildByTag(TAG_FLASK).getChildByTag(TAG_FLASK1).getChildByTag(TAG_KEROSENE1);
					var kerosene2 = ll.run.getChildByTag(TAG_FLASK).getChildByTag(TAG_FLASK2).getChildByTag(TAG_KEROSENE2);
					kerosene1.runAction(cc.scaleTo(3, 1, 2.1));
					kerosene2.runAction(cc.scaleTo(3, 1, 3.2));
				}, this),cc.delayTime(3.2),cc.callFunc(function() {
					var show = new ShowTip("当电流相等时，电阻越大，\n电流产生的热量越多",cc.p(290,440));
				}, this),cc.delayTime(1),cc.callFunc(function() {
					gg.flow.next();
				}, this));
				p.runAction(seq);
			}else if(action==ACTION_DO2){
				var move = cc.moveTo(1,cc.p(168,171));
				var seq = cc.sequence(cc.callFunc(function() {
					var show = new ShowTip("调整滑片，至电流表读数为2.0 A，\n等待3分钟",cc.p(995,530),true);
					var finger = ll.run.getChildByTag(TAG_AMMETER).getChildByTag(TAG_AMMETER_BODY).getChildByTag(TAG_AMMETER_FINGER);
					var rot1 = cc.rotateBy(0.5, 39);
					var rot2 = cc.rotateBy(0.5, -6);
					var rot3 = cc.rotateBy(0.5, 3);
					var seq1 = cc.sequence(rot1,rot2,rot3);
					finger.runAction(seq1);
				}, this),move,cc.delayTime(0.7),cc.callFunc(function() {	
					ll.run.clock.loadTip("#tool/tip1.png");
					ll.run.clock.doTime(3,0);
					var kerosene1 = ll.run.getChildByTag(TAG_FLASK).getChildByTag(TAG_FLASK1).getChildByTag(TAG_KEROSENE1);
					var kerosene2 = ll.run.getChildByTag(TAG_FLASK).getChildByTag(TAG_FLASK2).getChildByTag(TAG_KEROSENE2);
					kerosene1.runAction(cc.scaleTo(3, 1, 3.5));
					kerosene2.runAction(cc.scaleTo(3, 1, 6));
				}, this),cc.delayTime(3.2),cc.callFunc(function() {
					var show = new ShowTip("当电阻相等时，电流越大，\n电流产生的热量就越多",cc.p(290,440));
				}, this),cc.delayTime(1),cc.callFunc(function() {
					gg.flow.next();
				}, this));
				p.runAction(seq);
			}
			break;
		default:
			break;
		}
	},
	onExit:function(){
		this._super();
		this.callNext.release();
	}
})